package com.zjl.daoImpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;

import com.util.DBManager;
import com.util.QueryDataResult;
import com.zjl.entity.ManaBean;
import com.zjl.entity.StudentBean;

public class ManageDaoImpl {
	
	
	
	
	/*
	 * ManaBean[] sBeans=new ManaBean[50];//数组添加位置 Scanner scanner=new
	 * Scanner(System.in); //显示所有管理者 public void showALL() { ArrayList<ManaBean>
	 * aList=new ArrayList<ManaBean>(); String
	 * sqlString="select manaid,mananame,pwd from mana"; QueryDataResult
	 * rSet=DBManager.excuteQuery(sqlString); if (rSet!=null) { try { ResultSet
	 * rsSet=rSet.rs; while (rsSet.next()) { aList.add(new
	 * ManaBean(rsSet.getInt("manaid"),rsSet.getString("mananame"),rsSet.getInt(
	 * "pwd"))); } } catch (SQLException e) { e.printStackTrace(); } } rSet.close();
	 * System.out.println("管理id\t用户名\t密码"); for (ManaBean pBean : aList) {
	 * System.out.println(pBean.getManaid()+"\t"+pBean.getMananame()+"\t"+pBean.
	 * getPwd()); } }
	 * 
	 * //判断manaid是否存在 public ManaBean selectById(int manaid) { String
	 * sql="select manaid,mananame,pwd from mana where manaid="+manaid;
	 * QueryDataResult queryDataResult =DBManager.excuteQuery(sql); try { ResultSet
	 * rsSet=queryDataResult.rs; if (rsSet.next()) {
	 * //System.out.println("manaid重复"); return new
	 * ManaBean(rsSet.getInt("manaid"),rsSet.getString("mananame"),rsSet.getInt(
	 * "pwd")); } } catch (Exception e) { // TODO: handle exception
	 * e.printStackTrace(); } return null; } //添加 public void addmana() {
	 * System.out.println("管理id"); int manaid=scanner.nextInt(); ManaBean
	 * pBean=selectById(manaid); if (pBean!=null) {
	 * System.out.println("管理id重复,请重新添加"); }else { System.out.println("用户名"); String
	 * mananame=scanner.next(); System.out.println("密码"); int pwd=scanner.nextInt();
	 * String
	 * sqlString="insert into mana(manaid,mananame,pwd) values('"+manaid+"','"+
	 * mananame+"','"+pwd+"')"; int result=DBManager.excuteUpdate(sqlString);
	 * System.out.println(result>0?"添加成功":"添加失败"); }
	 * 
	 * } //修改
	 * 
	 * public void manaUpdate() { System.out.println("请输入要改的管理id"); int
	 * manaid=scanner.nextInt(); ManaBean pBean=selectById(manaid); if (pBean==null)
	 * { System.out.println("管理id不存在,无法修改"); }else { String
	 * mananame=pBean.getMananame(); int pwd=pBean.getPwd();
	 * System.out.println("是否修改用户名 y/n"); String str=scanner.next(); if
	 * (str.equals("y")) { System.out.println("请输入需要修改的用户名");
	 * mananame=scanner.next(); } System.out.println("是否修改密码 y/n");
	 * str=scanner.next(); if (str.equals("y")) { System.out.println("请输入需要修改的密码");
	 * pwd=scanner.nextInt(); } String
	 * sqlString="UPDATE mana SET mananame='"+mananame+"',pwd='"+
	 * pwd+"' WHERE manaid='"+manaid+"'"; int
	 * result=DBManager.excuteUpdate(sqlString);
	 * System.out.println(result>0?"修改成功":"修改失败"); }
	 * 
	 * } //判断mananame是否存在 public ManaBean selectById1(String mananame) { String
	 * sql="select manaid,mananame,pwd from mana where mananame='"+mananame+"'";
	 * QueryDataResult queryDataResult =DBManager.excuteQuery(sql); try { ResultSet
	 * rsSet=queryDataResult.rs; if (rsSet.next()) { return new
	 * ManaBean(rsSet.getInt("manaid"),rsSet.getString("mananame"),rsSet.getInt(
	 * "pwd")); } } catch (Exception e) { // TODO: handle exception
	 * e.printStackTrace(); } return null; }
	 * 
	 * //删除 public void deletemana() { System.out.println("请输入要删除的用户名"); String
	 * mananame=scanner.next(); ManaBean pBean=selectById1(mananame); if
	 * (pBean==null) { System.out.println("该用户不存在,无法删除"); }else { String
	 * sqlString="DELETE from mana WHERE mananame='"+mananame+"'"; int
	 * result=DBManager.excuteUpdate(sqlString);
	 * System.out.println(result>0?"删除成功":"删除失败"); } }
	 */
	 
}
